#include<stdio.h>
#include<stdlib.h>
#include<time.h>

#define N 10

int bubble_sort(int arr[], int n);
int get_randarr(int arr[], int n);
int main()
{
	int arr[N] = {0};
	get_randarr(arr, N);
	bubble_sort(arr, N);
	for(int i = 0; i < N; i++){
		printf("%d ", arr[i]);
	}
	printf("\n");
	return 0;
}



int bubble_sort(int arr[], int n){
	int i;
	int j;

	for(i = 0; i < n-1; i++){
		int flag = 0;
		for(j = 0; j < n-1-i; j++){
			if(arr[j] > arr[j+1]){
				int tem = arr[j];
				arr[j] = arr[j+1];
				arr[j+1] = tem;
				flag = 1;
			}
		}
		if(0 == flag){
			break;
		}
	}
	return 0;
}

int get_randarr(int arr[], int n){
	srand(time(NULL));
	for(int i = 0; i < n; i++){
		arr[i] = rand()%100;
	}
	return 0;
}

